<%@ page contentType="text/html; charset=utf-8" language="java"
	import="java.sql.*" errorPage="" pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="iwpl.teky.sample.daos.*"%>
<%@page import="iwpl.teky.sample.entities.*"%>
<%@page import="iwpl.teky.sample.servelet.*"%>
<%@page import="iwpl.teky.sample.interfaces.*"%>
<%@page import="iwpl.teky.sample.entitymanagerhelper.*"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Untitled Document</title>

		<script type="text/javascript">
			function Confirm(id) 
			{
				var text = confirm("Are you sure ?");
				
				if (text == true)
				{
					//alert("Okey, Deleted !!!");
					location.href = "./servlet/MyControl?delete=" + id;
				}
				else 
				{
					alert("What ever !!!");
				}
			}
		</script>
	</head>

	<body>
		<form id="form1" name="form1" method="get" action="./DUICate.jsp">
			<table width="376" border="0">
				<tr>
					<td colspan="2">
						Quan ly chu de
					</td>
				</tr>
				<tr>
					<td width="98">
						<div align="center">
							<input type="submit" name="BtnAdd" value="Them" />
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td>
						Trang thai
					</td>
					<td>
						<select name="CboStatus">
							<option value="True">
								True
							</option>
							<option value="False">
								False
							</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						&nbsp;


					</td>
					<td>
						&nbsp;


					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div>
							<table width="100%" border="0">
								<tr>
									<td>
										STT
									</td>
									<td>
										ID
									</td>
									<td>
										Ten Chu De
									</td>
									<td>
										Trang Thai
									</td>
									<td>
										Sua
									</td>
									<td">
										Xoa
									</td>
								</tr>
								<%
									CategoriesDAO dao = new CategoriesDAO();
									List<Categories> list = dao.findAll();
									
									int i = 0;
									

									for(Iterator<Categories> it = list.iterator(); it.hasNext();)
									{
										Categories cate = (Categories) it.next();
											i++;

											if (i % 2 != 0) {
												out.println("<tr bgcolor=\"#CCFFFF\"><td>");
											} else {
												out.println("<tr bgcolor=\"#99CCCC\"><td>");
											}
											out.println(i + "</td>");
											out.println("<td>" + cate.getCategoryId() + "</td>");
											out
													.println("<td>" + cate.getCategoryName()
															+ "</td>");
											out.println("<td>" + cate.getStatus() + "</td>");
											//out.println("<td>" + rsq.getString("CountID") + "</td></tr>");
											//out.println("<td>" + rs.getString("Status") + "</td></tr>");
											out.println("<td><a href=" + "/SampleJPAOnNews/UCate.jsp?id="
													+ cate.getCategoryId().toString() + " /><img src="
													+ "./Pics/Edit.jpg" + " /></td>");
											/*out.println("<td><a href=" + "./servlet/myservlet?delete="
													+ rs.getString("CategoryID") + " /><img src="
													+ "./Pics/Delete.jpg" + " /></td></tr>");*/
											//out.println("<td><img src=\"./Pics/Delete.jpg\" onclick =\"Confirm()\"/></td></tr>");
											out.println("<td><a href=javascript:Confirm('"
													+ cate.getCategoryId() + "') /><img src="
													+ "./Pics/Delete.jpg" + " /></td></tr>");
										}
								%>
							</table>
							<div align="center"></div>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div align="center">
							<input type="submit" name="BtnAdd2" value="Them" />
						</div>
					</td>
					<td>
						<div align="center">
							<input type="submit" name="BtnExit2" value="Thoat" />
						</div>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>